<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>班级信息</title>
		<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="stylesheet" href="../../css/font.css">
    <link rel="stylesheet" href="../../css/login.css">
	  <link rel="stylesheet" href="../../css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script src="../../lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
		<div class="layui-row">
			<form class="layui-form">
				<!-- 怎么一个div就相当于是一行数据  可以自己多复制一个就等于是添加了一行 -->
				<div class="layui-form-item">
					
					<!-- 一个lable 加它下面的div 就相当于是 一个  td -->
					<label for="lawId" class="layui-form-label">
						<span class="x-red">*</span>编号
					</label>
					<div class="layui-input-inline">
						<input type="text" autocomplete="off" placeholder="编号无需填写" readonly class="layui-input layui-disabled" >
					</div>
					
					<label for="lawTitle" class="layui-form-label">
						<span class="x-red">*</span>法律标题
					</label>
					<div class="layui-input-inline">
						<input type="text" id="lawTitle" name="lawTitle" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
					
				</div>
				
				<div class="layui-form-item">
					<label for="lawContent" class="layui-form-label"> <span
						class="x-red">*</span>法律内容
					</label>
					<div class="layui-input-inline">
						<input type="text" id="lawContent" name="lawContent" lay-verify="required" autocomplete="off" class="layui-input">
					</div>
				</div>
				
				
				<div class="layui-form-item">
					<label for="L_repass" class="layui-form-label"></label>
					<button class="layui-btn" lay-filter="add" lay-submit="">保存</button>
				</div>
				
			</form>
		</div>
	</div>

</body>
        <script>
        layui.use([ 'form', 'layer' ], function() {
			$ = layui.jquery;
			var form = layui.form, 
			layer = layui.layer;
			
			
			//监听提交 这里的 submit是必须的关键之  然后括号里面的add 就是表单中的提交按钮中的lay-filter属性值   lay-filter="add"
			form.on('submit(add)', function(data) {
				console.log(data);
				
				 
				 $.ajax({
		            //请求方式
		            type : "POST",
		            //请求的媒体类型
		            //contentType: "application/json;charset=UTF-8",
		            //请求地址
		            url : "/../law/insertLaw",
		            //数据，(json字符串 JSON.stringify(data)),
		            data : data.field,
		            //请求成功
		            success : function(result) {
		            	if(result>0){
		            		//发异步，把数据提交给springmvc
							layer.alert("保存成功", {
								icon : 6
							}, function() {
								// 获得frame索引
								var index = parent.layer.getFrameIndex(window.name);
								//关闭当前frame
								parent.layer.close(index);
								
								parent.location.reload();//刷新父页面更新修改后的表格数据
							});
		            	}else{
		            		//发异步，把数据提交给
							layer.alert("保存失败！", {
								icon : 6
							});
		            	}
		            }
		        });
				return false;
			});

		});
        </script>
</html>